#pragma once

#include "share/Callback.h"
#include "share/DataBlock.h"
#include "net/NetIO.h"

class EventHandler
{
	typedef Callback< void (EventHandle, int, int, DataBlock *, void *) > RWCallback;
	typedef Callback< void (int, EventHandle, void *) > ACCallback;
public:
	EventHandler (void) {};
public:
	~EventHandler (void) {};

	void read_complete (EventHandle handle, int errcode, int bytes_transferred, DataBlock *data_block, void *act)
	{
		read_callback_ (handle, errcode, bytes_transferred, data_block, act);
	}
	void write_complete (EventHandle handle, int errcode, int bytes_transferred, DataBlock *data_block, void *act)
	{
		write_callback_ (handle, errcode, bytes_transferred, data_block, act);
	}
	void connect_complete (int errcode, EventHandle handle, void *act)
	{
		connect_callback_ (errcode, handle, act);
	}
	void accept_complete (int errcode, EventHandle handle, void *act)
	{
		accept_callback_ (errcode, handle, act);
	}

protected:

	RWCallback read_callback_;
	RWCallback write_callback_;
	ACCallback connect_callback_;
	ACCallback accept_callback_;

	EventHandle handle_;
};
